#pragma once
#include <typescommon.h>

// donot use = for cstring.
// use cstrCpx replease.
struct cstring
{
    char *str;
    uint32_t total; // malloc size.
    uint32_t size;  // string size
};

#define cstrInitVal  \
    (struct cstring) \
    {                \
        NULL, 0, 0   \
    }
#define cstrDef(tp) struct cstring tp = cstrInitVal;
// uint32_t memcpyV1(void *dec, uint32_t dlen, const void *src, uint32_t slen);
void cstrFree(struct cstring *decs);
uint32_t cstrResize(struct cstring *decs, uint32_t rlen);
uint32_t cstrCpMem(struct cstring *decs, const void *srcs, uint32_t slen);
uint32_t cstrCpStr(struct cstring *decs, const char *instr);
uint32_t cstrCpCstr(struct cstring *decs, struct cstring *srcs);
uint32_t cstrCatMem(struct cstring *decs, const void *srcs, uint32_t slen);
uint32_t cstrCatStr(struct cstring *decs, const char *instr);
uint32_t cstrCatCstr(struct cstring *decs, struct cstring *srcs);
void cstrMvCstr(struct cstring *decs, struct cstring *srcs);
uint32_t cstrSprint(struct cstring *decs, uint32_t maxsize, const char *format, ...);
